/*
 * @Author: 悦者生存 1002783067@qq.com
 * @Date: 2023-10-29 09:30:44
 * @LastEditors: 悦者生存 1002783067@qq.com
 * @LastEditTime: 2023-11-02 21:29:47
 * @FilePath: /koa2-ts-template/src/routes/index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// file -> ./routes/index.ts
import { SwaggerRouter } from 'koa-swagger-decorator';
import UserController from '../controller/user';
import { registerExtraComponents } from '../common/swagger-extra';

const router = new SwaggerRouter({
  spec: {
    info: {
      title: 'koa模版',
      version: 'v1.0',
    },
  },
  swaggerHtmlEndpoint: '/swagger-html',
  swaggerJsonEndpoint: '/swagger-json',
});

router.prefix('/api');

registerExtraComponents(router.registry);

// apply swagger docs routes
// 只开发环境运行
if (process.env.NODE_ENV === 'development') {
  router.swagger();
}
// register user defined routes implementation
router.applyRoute(UserController);
// .applyRoute(DemoController); // chained for more then one controller imports

export default router;
